package com.wb.mas.ui.auth;

import android.app.Application;

import androidx.annotation.NonNull;

import com.wb.mas.app.Constants;
import com.wb.mas.data.DemoRepository;
import com.wb.mas.entity.RootApiBean;
import com.wb.mas.entity.SubmitedAuthResponse;
import com.wb.mas.ui.base.viewmodel.ToolbarViewModel;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import me.goldze.mvvmhabit.utils.KLog;

public class AuthBaseViewModel extends ToolbarViewModel {
    public AuthBaseViewModel(@NonNull Application application, DemoRepository model) {
        super(application, model);
    }


    /**
     * 30.资料回退时获取认证信息的
     * {
     * "authPageCode": [
     * "company_code"   //那一步的
     * ],
     * "channel": "1",
     * "commonParam": 公参
     * "userUuid": "201904230822222222"
     * }
     */
    public void getSubmitedInfo(String authCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("authPageCode", authCode);
        model.getSubmitedAuthInfo(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<SubmitedAuthResponse>() {
                    @Override
                    public void accept(SubmitedAuthResponse response) throws Exception {

                        onSubmittedResponse(response);
                        KLog.i("upload img suc");
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        KLog.e("upload fail:" + throwable.getMessage());
                    }
                });
    }

    protected void onSubmittedResponse(SubmitedAuthResponse response) {

    }


}
